package com.future.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.future.domain.DTO.UserBackEndDTO;
import com.future.domain.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User>{

    String getClassName(@Param("user_id") Long userId);


    List<Integer> getUserRole(@Param("user_id") Long userId);

    /**
     * 搜索用户
     * @param page 分页参数
     * @param keyword 搜索关键词
     * @return 分页用户列表
     */
    @Select("SELECT * FROM `user` " +
            "WHERE status != 2 " +
            "AND (username LIKE CONCAT('%', #{keyword}, '%') " +
            "     OR account LIKE CONCAT('%', #{keyword}, '%') " +
            "     OR email LIKE CONCAT('%', #{keyword}, '%')) " +
            "ORDER BY created_at DESC")
    Page<User> receptionSearchUsers(Page<User> page, @Param("keyword") String keyword);
    @Select("SELECT * FROM `user` " +
            "WHERE (username LIKE CONCAT('%', #{keyword}, '%') " +
            "     OR account LIKE CONCAT('%', #{keyword}, '%') " +
            "     OR email LIKE CONCAT('%', #{keyword}, '%')) " +
            "ORDER BY created_at DESC")
    Page<User> backgroundSearchUsers(Page<User> page, @Param("keyword") String keyword);


    Page<UserBackEndDTO> selectMyClassStudent(Page<UserBackEndDTO> page, String keyword,Long teacherId);

}


